# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=jami-qt
pkgver=20230925
pkgrel=0
_gitrev=70ce0c091e4aa7abec2826ab826ae0417f593f0d
_sortfilter=a2a0c72e4db38e1c5478bd3e0f67ff99fae11f00
pkgdesc="Free and universal communication platform which preserves the users’ privacy and freedoms (Qt client)"
url="https://jami.net"
arch="all !s390x !ppc64le !riscv64" # missing jami-daemon dependency
license="GPL-3.0-or-later"
depends="qt6-qtbase-sqlite"
makedepends="
	cmake
	jami-daemon-dev
	libqrencode-dev
	md4c-dev
	python3
	qt6-qt5compat-dev
	qt6-qtmultimedia-dev
	qt6-qtnetworkauth-dev
	qt6-qtpositioning-dev
	qt6-qtsvg-dev
	qt6-qttools-dev
	qt6-qtwebchannel-dev
	samurai
	tidyhtml-dev
	"
subpackages="$pkgname-doc $pkgname-lang"
source="$pkgname-$_gitrev.tar.gz::https://git.jami.net/savoirfairelinux/jami-client-qt/-/archive/$_gitrev/jami-client-qt-$_gitrev.tar.gz
	sortfilterproxymodel-$_sortfilter.tar.gz::https://github.com/atraczyk/SortFilterProxyModel/archive/$_sortfilter.tar.gz
	drop-qt-version-check.patch
	system.patch
	"
builddir="$srcdir/jami-client-qt-$_gitrev"

prepare() {
	default_prepare

	rmdir 3rdparty/SortFilterProxyModel
	ln -sfv "$srcdir"/SortFilterProxyModel-$_sortfilter 3rdparty/SortFilterProxyModel
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja -Wno-dev \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DENABLE_LIBWRAP=ON \
		-DWITH_WEBENGINE=false
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

lang() {
	amove usr/share/jami/translations

}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
97e15b8be1bfe334270a0f5f1bc6a5a3646f8bcf04027b83fd69b56f75c30a1124a2ee92fb9c0f10a56e523a2f9b2060f909e3f26f20db174b2cc11c162d11ed  jami-qt-70ce0c091e4aa7abec2826ab826ae0417f593f0d.tar.gz
9c02e206829ea12fb77fdd34e4ac42572d38e33d8ed60534f6d6495ac53c8449c57162fe09060a1e1de05b01f6fdbefb63a614860dd402af4911749aa8c012f8  sortfilterproxymodel-a2a0c72e4db38e1c5478bd3e0f67ff99fae11f00.tar.gz
5bc7d449bd7b1b1176361126ef58737c69262ca7cd2f6c96695c142a793a1eb74e1cfd2a10e6677eed3a47ffb3789c7f727d8ffbd8e708abfa2319b43d3d930f  drop-qt-version-check.patch
6886c36ba43110b1519cb763fad60a4ffa1ea0170a5482a96a730d28c58d03e4164b2d8777a035fa8e07257e589eda14c97ffd3e870c7d0bd5de2e8850638506  system.patch
"
